package UML_ER.diagram.part;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.View;

import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;
import UML_ER.Aggregation;
import UML_ER.Attribute;
import UML_ER.BinaryRelationship;
import UML_ER.Composition;
import UML_ER.ERmodel;
import UML_ER.Element;
import UML_ER.Entity;
import UML_ER.Generalization;
import UML_ER.OntologyReference;
import UML_ER.Relationship;

import UML_ER.Role;
import UML_ER.UML_ERPackage;
import UML_ER.diagram.edit.parts.AggregationEditPart;
import UML_ER.diagram.edit.parts.Attribute2EditPart;
import UML_ER.diagram.edit.parts.AttributeEditPart;
import UML_ER.diagram.edit.parts.BinaryRelationship2EditPart;
import UML_ER.diagram.edit.parts.BinaryRelationshipAttributesEditPart;
import UML_ER.diagram.edit.parts.BinaryRelationshipEditPart;
import UML_ER.diagram.edit.parts.BinaryRelationshipTargetEditPart;
import UML_ER.diagram.edit.parts.CompositionEditPart;
import UML_ER.diagram.edit.parts.ERmodelEditPart;
import UML_ER.diagram.edit.parts.EntityAttributes2EditPart;
import UML_ER.diagram.edit.parts.EntityAttributesEditPart;
import UML_ER.diagram.edit.parts.EntityEditPart;
import UML_ER.diagram.edit.parts.GeneralizationEditPart;
import UML_ER.diagram.edit.parts.OntologyReference2EditPart;
import UML_ER.diagram.edit.parts.OntologyReferenceEditPart;
import UML_ER.diagram.edit.parts.RelationshipEditPart;
import UML_ER.diagram.edit.parts.RoleEditPart;
import UML_ER.diagram.providers.UML_ERElementTypes;

/**
 * @generated
 */
public class UML_ERDiagramUpdater {

	/**
	 * @generated
	 */
	public static List<UML_ERNodeDescriptor> getSemanticChildren(View view) {
		switch (UML_ERVisualIDRegistry.getVisualID(view)) {
		case ERmodelEditPart.VISUAL_ID:
			return getERmodel_1000SemanticChildren(view);
		case EntityAttributesEditPart.VISUAL_ID:
			return getEntityAttributes_7005SemanticChildren(view);
		case EntityAttributes2EditPart.VISUAL_ID:
			return getEntityAttributes_7006SemanticChildren(view);
		case BinaryRelationshipAttributesEditPart.VISUAL_ID:
			return getBinaryRelationshipAttributes_7004SemanticChildren(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERNodeDescriptor> getERmodel_1000SemanticChildren(
			View view) {
		if (!view.isSetElement()) {
			return Collections.emptyList();
		}
		ERmodel modelElement = (ERmodel) view.getElement();
		LinkedList<UML_ERNodeDescriptor> result = new LinkedList<UML_ERNodeDescriptor>();
		for (Iterator<?> it = modelElement.getInstanceElement().iterator(); it
				.hasNext();) {
			Element childElement = (Element) it.next();
			int visualID = UML_ERVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == EntityEditPart.VISUAL_ID) {
				result.add(new UML_ERNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == BinaryRelationshipEditPart.VISUAL_ID) {
				result.add(new UML_ERNodeDescriptor(childElement, visualID));
				continue;
			}
			if (visualID == RelationshipEditPart.VISUAL_ID) {
				result.add(new UML_ERNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERNodeDescriptor> getEntityAttributes_7005SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Entity modelElement = (Entity) containerView.getElement();
		LinkedList<UML_ERNodeDescriptor> result = new LinkedList<UML_ERNodeDescriptor>();
		for (Iterator<?> it = modelElement.getAttribute().iterator(); it
				.hasNext();) {
			Attribute childElement = (Attribute) it.next();
			int visualID = UML_ERVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == AttributeEditPart.VISUAL_ID) {
				result.add(new UML_ERNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERNodeDescriptor> getEntityAttributes_7006SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Entity modelElement = (Entity) containerView.getElement();
		LinkedList<UML_ERNodeDescriptor> result = new LinkedList<UML_ERNodeDescriptor>();
		for (Iterator<?> it = modelElement.getOntologyReference().iterator(); it
				.hasNext();) {
			OntologyReference childElement = (OntologyReference) it.next();
			int visualID = UML_ERVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == OntologyReferenceEditPart.VISUAL_ID) {
				result.add(new UML_ERNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * 
	 */
	public static List<UML_ERNodeDescriptor> getBinaryRelationshipAttributes_7004SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Relationship modelElement = (Relationship) containerView.getElement();
		LinkedList<UML_ERNodeDescriptor> result = new LinkedList<UML_ERNodeDescriptor>();
		for (Iterator<?> it = modelElement.getAttribute().iterator(); it
				.hasNext();) {
			Attribute childElement = (Attribute) it.next();
			int visualID = UML_ERVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == AttributeEditPart.VISUAL_ID) {
				result.add(new UML_ERNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getContainedLinks(View view) {
		switch (UML_ERVisualIDRegistry.getVisualID(view)) {
		case ERmodelEditPart.VISUAL_ID:
			return getERmodel_1000ContainedLinks(view);
		case EntityEditPart.VISUAL_ID:
			return getEntity_2003ContainedLinks(view);
		case BinaryRelationshipEditPart.VISUAL_ID:
			return getBinaryRelationship_2008ContainedLinks(view);
		case RelationshipEditPart.VISUAL_ID:
			return getRelationship_2009ContainedLinks(view);
		case AttributeEditPart.VISUAL_ID:
			return getAttribute_3001ContainedLinks(view);
		case OntologyReferenceEditPart.VISUAL_ID:
			return getOntologyReference_3002ContainedLinks(view);
		case Attribute2EditPart.VISUAL_ID:
			return getAttribute_3003ContainedLinks(view);
		case BinaryRelationship2EditPart.VISUAL_ID:
			return getBinaryRelationship_4014ContainedLinks(view);
		case AggregationEditPart.VISUAL_ID:
			return getAggregation_4015ContainedLinks(view);
		case GeneralizationEditPart.VISUAL_ID:
			return getGeneralization_4011ContainedLinks(view);
		case RoleEditPart.VISUAL_ID:
			return getRole_4024ContainedLinks(view);
		case CompositionEditPart.VISUAL_ID:
			return getComposition_4025ContainedLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getIncomingLinks(View view) {
		switch (UML_ERVisualIDRegistry.getVisualID(view)) {
		case EntityEditPart.VISUAL_ID:
			return getEntity_2003IncomingLinks(view);
		case BinaryRelationshipEditPart.VISUAL_ID:
			return getBinaryRelationship_2008IncomingLinks(view);
		case RelationshipEditPart.VISUAL_ID:
			return getRelationship_2009IncomingLinks(view);
		case AttributeEditPart.VISUAL_ID:
			return getAttribute_3001IncomingLinks(view);
		case OntologyReferenceEditPart.VISUAL_ID:
			return getOntologyReference_3002IncomingLinks(view);
		case Attribute2EditPart.VISUAL_ID:
			return getAttribute_3003IncomingLinks(view);
		case BinaryRelationship2EditPart.VISUAL_ID:
			return getBinaryRelationship_4014IncomingLinks(view);
		case AggregationEditPart.VISUAL_ID:
			return getAggregation_4015IncomingLinks(view);
		case GeneralizationEditPart.VISUAL_ID:
			return getGeneralization_4011IncomingLinks(view);
		case RoleEditPart.VISUAL_ID:
			return getRole_4024IncomingLinks(view);
		case CompositionEditPart.VISUAL_ID:
			return getComposition_4025IncomingLinks(view);
		}
		return Collections.emptyList();
	}

	private static List<UML_ERLinkDescriptor> getAttribute_3005IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getOutgoingLinks(View view) {
		switch (UML_ERVisualIDRegistry.getVisualID(view)) {
		case EntityEditPart.VISUAL_ID:
			return getEntity_2003OutgoingLinks(view);
		case BinaryRelationshipEditPart.VISUAL_ID:
			return getBinaryRelationship_2008OutgoingLinks(view);
		case RelationshipEditPart.VISUAL_ID:
			return getRelationship_2009OutgoingLinks(view);
		case AttributeEditPart.VISUAL_ID:
			return getAttribute_3001OutgoingLinks(view);
		case OntologyReferenceEditPart.VISUAL_ID:
			return getOntologyReference_3002OutgoingLinks(view);
		case Attribute2EditPart.VISUAL_ID:
			return getAttribute_3003OutgoingLinks(view);
		case BinaryRelationship2EditPart.VISUAL_ID:
			return getBinaryRelationship_4014OutgoingLinks(view);
		case AggregationEditPart.VISUAL_ID:
			return getAggregation_4015OutgoingLinks(view);
		case GeneralizationEditPart.VISUAL_ID:
			return getGeneralization_4011OutgoingLinks(view);
		case RoleEditPart.VISUAL_ID:
			return getRole_4024OutgoingLinks(view);
		case CompositionEditPart.VISUAL_ID:
			return getComposition_4025OutgoingLinks(view);
		}
		return Collections.emptyList();
	}

	private static List<UML_ERLinkDescriptor> getAttribute_3005OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getERmodel_1000ContainedLinks(
			View view) {
		ERmodel modelElement = (ERmodel) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_BinaryRelationship_4014(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Aggregation_4015(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Generalization_4011(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Composition_4025(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getEntity_2003ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * 
	 */
	public static List<UML_ERLinkDescriptor> getBinaryRelationship_2008ContainedLinks(
			View view) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		if (UML_ERPackage.eINSTANCE.getBinaryRelationship().isSuperTypeOf(
				view.getElement().eClass())) {
			BinaryRelationship modelElement = (BinaryRelationship) view
					.getElement();

			result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
			result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));

		}

		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getRelationship_2009ContainedLinks(
			View view) {
		Relationship modelElement = (Relationship) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAttribute_3001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getOntologyReference_3002ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAttribute_3003ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getGeneralization_4011ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getRole_4024ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getComposition_4025ContainedLinks(
			View view) {
		Composition modelElement = (Composition) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getBinaryRelationship_4014ContainedLinks(
			View view) {
		BinaryRelationship modelElement = (BinaryRelationship) view
				.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAggregation_4015ContainedLinks(
			View view) {
		Aggregation modelElement = (Aggregation) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getEntity_2003IncomingLinks(
			View view) {
		Entity modelElement = (Entity) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_Generalization_4011(
				modelElement, crossReferences));
		result.addAll(getIncomingTypeModelFacetLinks_Role_4024(modelElement,
				crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getBinaryRelationship_2008IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getRelationship_2009IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAttribute_3001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getOntologyReference_3002IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAttribute_3003IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getGeneralization_4011IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getRole_4024IncomingLinks(View view) {
		Role modelElement = (Role) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_BinaryRelationship_4014(
				modelElement, crossReferences));
		result.addAll(getIncomingTypeModelFacetLinks_Aggregation_4015(
				modelElement, crossReferences));
		result.addAll(getIncomingFeatureModelFacetLinks_BinaryRelationship_Target_4022(
				modelElement, crossReferences));
		result.addAll(getIncomingTypeModelFacetLinks_Composition_4025(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getComposition_4025IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getBinaryRelationship_4014IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAggregation_4015IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getEntity_2003OutgoingLinks(
			View view) {
		Entity modelElement = (Entity) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingTypeModelFacetLinks_Generalization_4011(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getBinaryRelationship_2008OutgoingLinks(
			View view) {
		BinaryRelationship modelElement = (BinaryRelationship) view
				.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getRelationship_2009OutgoingLinks(
			View view) {
		Relationship modelElement = (Relationship) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAttribute_3001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getOntologyReference_3002OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAttribute_3003OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getGeneralization_4011OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getRole_4024OutgoingLinks(View view) {
		Role modelElement = (Role) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingTypeModelFacetLinks_BinaryRelationship_4014(modelElement));
		result.addAll(getOutgoingTypeModelFacetLinks_Aggregation_4015(modelElement));
		result.addAll(getOutgoingTypeModelFacetLinks_Composition_4025(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getComposition_4025OutgoingLinks(
			View view) {
		Composition modelElement = (Composition) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getBinaryRelationship_4014OutgoingLinks(
			View view) {
		BinaryRelationship modelElement = (BinaryRelationship) view
				.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<UML_ERLinkDescriptor> getAggregation_4015OutgoingLinks(
			View view) {
		Aggregation modelElement = (Aggregation) view.getElement();
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		result.addAll(getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(modelElement));
		result.addAll(getContainedTypeModelFacetLinks_Role_4024(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getContainedTypeModelFacetLinks_Generalization_4011(
			ERmodel container) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Generalization) {
				continue;
			}
			Generalization link = (Generalization) linkObject;
			if (GeneralizationEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			Entity dst = link.getGeneral();
			Entity src = link.getSpecific();
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.Generalization_4011,
					GeneralizationEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getContainedTypeModelFacetLinks_Role_4024(
			Relationship container) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getRole().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Role) {
				continue;
			}
			Role link = (Role) linkObject;
			if (RoleEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			Entity dst = link.getConnectedEntity();
			result.add(new UML_ERLinkDescriptor(container, dst, link,
					UML_ERElementTypes.Role_4024, RoleEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * 
	 */
	private static Collection<UML_ERLinkDescriptor> getContainedTypeModelFacetLinks_Composition_4025(
			ERmodel container) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Composition) {
				continue;
			}
			Composition link = (Composition) linkObject;
			if (CompositionEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			//List targets = link.getRole();
			//Object theTarget = targets.size() == 1 ? targets.get(0) : null;
			Object theTarget = link.getTarget().getConnectedEntity();
			if (false == theTarget instanceof Entity) {
				continue;
			}
			Entity dst = (Entity) theTarget;
			//List sources = link.getRole();
			//Object theSource = sources.size() == 1 ? sources.get(0) : null;
			Object theSource = link.getSource().getConnectedEntity();
			if (false == theSource instanceof Entity) {
				continue;
			}
			Entity src = (Entity) theSource;
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.Composition_4025,
					CompositionEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getIncomingTypeModelFacetLinks_BinaryRelationship_4014(
			Role target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != UML_ERPackage.eINSTANCE
					.getRelationship_Role()
					|| false == setting.getEObject() instanceof BinaryRelationship) {
				continue;
			}
			BinaryRelationship link = (BinaryRelationship) setting.getEObject();
			if (BinaryRelationship2EditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			List sources = link.getRole();
			Object theSource = sources.size() == 1 ? sources.get(0) : null;
			if (false == theSource instanceof Role) {
				continue;
			}
			Role src = (Role) theSource;
			result.add(new UML_ERLinkDescriptor(src, target, link,
					UML_ERElementTypes.BinaryRelationship_4014,
					BinaryRelationship2EditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getIncomingTypeModelFacetLinks_Aggregation_4015(
			Role target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != UML_ERPackage.eINSTANCE
					.getRelationship_Role()
					|| false == setting.getEObject() instanceof Aggregation) {
				continue;
			}
			Aggregation link = (Aggregation) setting.getEObject();
			if (AggregationEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			List sources = link.getRole();
			Object theSource = sources.size() == 1 ? sources.get(0) : null;
			if (false == theSource instanceof Role) {
				continue;
			}
			Role src = (Role) theSource;
			result.add(new UML_ERLinkDescriptor(src, target, link,
					UML_ERElementTypes.Aggregation_4015,
					AggregationEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getIncomingFeatureModelFacetLinks_BinaryRelationship_Target_4022(
			Role target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == UML_ERPackage.eINSTANCE
					.getBinaryRelationship_Target()) {
				result.add(new UML_ERLinkDescriptor(setting.getEObject(),
						target,
						UML_ERElementTypes.BinaryRelationshipTarget_4022,
						BinaryRelationshipTargetEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * 
	 */
	private static Collection<UML_ERLinkDescriptor> getContainedTypeModelFacetLinks_BinaryRelationship_4014(
			ERmodel container) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof BinaryRelationship) {
				continue;
			}
			BinaryRelationship link = (BinaryRelationship) linkObject;
			if (BinaryRelationship2EditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			//List targets = link.getRole();
			//Object theTarget = targets.size() == 2 ? targets.get(0) : null;
			Object theTarget = link.getTarget().getConnectedEntity();
			if (false == theTarget instanceof Entity) {
				continue;
			}
			Entity dst = (Entity) theTarget;
			//List sources = link.getRole();
			//Object theSource = sources.size() == 1 ? sources.get(0) : null;
			Object theSource = link.getSource().getConnectedEntity();
			if (false == theSource instanceof Entity) {
				continue;
			}
			Entity src = (Entity) theSource;
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.BinaryRelationship_4014,
					BinaryRelationship2EditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * 
	 */
	private static Collection<UML_ERLinkDescriptor> getContainedTypeModelFacetLinks_Aggregation_4015(
			ERmodel container) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Aggregation) {
				continue;
			}
			Aggregation link = (Aggregation) linkObject;
			if (AggregationEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			//List targets = link.getRole();
			//Object theTarget = targets.size() == 1 ? targets.get(0) : null;
			Object theTarget = link.getTarget().getConnectedEntity();
			if (false == theTarget instanceof Entity) {
				continue;
			}
			Entity dst = (Entity) theTarget;
			//List sources = link.getRole();
			//Object theSource = sources.size() == 1 ? sources.get(0) : null;
			Object theSource = link.getSource().getConnectedEntity();
			if (false == theSource instanceof Entity) {
				continue;
			}
			Entity src = (Entity) theSource;
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.Aggregation_4015,
					AggregationEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getIncomingTypeModelFacetLinks_Generalization_4011(
			Entity target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != UML_ERPackage.eINSTANCE
					.getGeneralization_General()
					|| false == setting.getEObject() instanceof Generalization) {
				continue;
			}
			Generalization link = (Generalization) setting.getEObject();
			if (GeneralizationEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			Entity src = link.getSpecific();
			result.add(new UML_ERLinkDescriptor(src, target, link,
					UML_ERElementTypes.Generalization_4011,
					GeneralizationEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getIncomingTypeModelFacetLinks_Role_4024(
			Entity target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != UML_ERPackage.eINSTANCE
					.getRole_ConnectedEntity()
					|| false == setting.getEObject() instanceof Role) {
				continue;
			}
			Role link = (Role) setting.getEObject();
			if (RoleEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			if (false == link.eContainer() instanceof Relationship) {
				continue;
			}
			Relationship container = (Relationship) link.eContainer();
			result.add(new UML_ERLinkDescriptor(container, target, link,
					UML_ERElementTypes.Role_4024, RoleEditPart.VISUAL_ID));

		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getIncomingTypeModelFacetLinks_Composition_4025(
			Role target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != UML_ERPackage.eINSTANCE
					.getRelationship_Role()
					|| false == setting.getEObject() instanceof Composition) {
				continue;
			}
			Composition link = (Composition) setting.getEObject();
			if (CompositionEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			List sources = link.getRole();
			Object theSource = sources.size() == 1 ? sources.get(0) : null;
			if (false == theSource instanceof Role) {
				continue;
			}
			Role src = (Role) theSource;
			result.add(new UML_ERLinkDescriptor(src, target, link,
					UML_ERElementTypes.Composition_4025,
					CompositionEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getOutgoingTypeModelFacetLinks_BinaryRelationship_4014(
			Role source) {
		ERmodel container = null;
		// Find container element for the link.
		// Climb up by containment hierarchy starting from the source
		// and return the first element that is instance of the container class.
		for (EObject element = source; element != null && container == null; element = element
				.eContainer()) {
			if (element instanceof ERmodel) {
				container = (ERmodel) element;
			}
		}
		if (container == null) {
			return Collections.emptyList();
		}
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof BinaryRelationship) {
				continue;
			}
			BinaryRelationship link = (BinaryRelationship) linkObject;
			if (BinaryRelationship2EditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			List targets = link.getRole();
			Object theTarget = targets.size() == 1 ? targets.get(0) : null;
			if (false == theTarget instanceof Role) {
				continue;
			}
			Role dst = (Role) theTarget;
			List sources = link.getRole();
			Object theSource = sources.size() == 1 ? sources.get(0) : null;
			if (false == theSource instanceof Role) {
				continue;
			}
			Role src = (Role) theSource;
			if (src != source) {
				continue;
			}
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.BinaryRelationship_4014,
					BinaryRelationship2EditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getOutgoingTypeModelFacetLinks_Aggregation_4015(
			Role source) {
		ERmodel container = null;
		// Find container element for the link.
		// Climb up by containment hierarchy starting from the source
		// and return the first element that is instance of the container class.
		for (EObject element = source; element != null && container == null; element = element
				.eContainer()) {
			if (element instanceof ERmodel) {
				container = (ERmodel) element;
			}
		}
		if (container == null) {
			return Collections.emptyList();
		}
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Aggregation) {
				continue;
			}
			Aggregation link = (Aggregation) linkObject;
			if (AggregationEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			List targets = link.getRole();
			Object theTarget = targets.size() == 1 ? targets.get(0) : null;
			if (false == theTarget instanceof Role) {
				continue;
			}
			Role dst = (Role) theTarget;
			List sources = link.getRole();
			Object theSource = sources.size() == 1 ? sources.get(0) : null;
			if (false == theSource instanceof Role) {
				continue;
			}
			Role src = (Role) theSource;
			if (src != source) {
				continue;
			}
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.Aggregation_4015,
					AggregationEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getOutgoingTypeModelFacetLinks_Generalization_4011(
			Entity source) {
		ERmodel container = null;
		// Find container element for the link.
		// Climb up by containment hierarchy starting from the source
		// and return the first element that is instance of the container class.
		for (EObject element = source; element != null && container == null; element = element
				.eContainer()) {
			if (element instanceof ERmodel) {
				container = (ERmodel) element;
			}
		}
		if (container == null) {
			return Collections.emptyList();
		}
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Generalization) {
				continue;
			}
			Generalization link = (Generalization) linkObject;
			if (GeneralizationEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			Entity dst = link.getGeneral();
			Entity src = link.getSpecific();
			if (src != source) {
				continue;
			}
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.Generalization_4011,
					GeneralizationEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<UML_ERLinkDescriptor> getOutgoingTypeModelFacetLinks_Composition_4025(
			Role source) {
		ERmodel container = null;
		// Find container element for the link.
		// Climb up by containment hierarchy starting from the source
		// and return the first element that is instance of the container class.
		for (EObject element = source; element != null && container == null; element = element
				.eContainer()) {
			if (element instanceof ERmodel) {
				container = (ERmodel) element;
			}
		}
		if (container == null) {
			return Collections.emptyList();
		}
		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		for (Iterator<?> links = container.getInstanceElement().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Composition) {
				continue;
			}
			Composition link = (Composition) linkObject;
			if (CompositionEditPart.VISUAL_ID != UML_ERVisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			List targets = link.getRole();
			Object theTarget = targets.size() == 1 ? targets.get(0) : null;
			if (false == theTarget instanceof Role) {
				continue;
			}
			Role dst = (Role) theTarget;
			List sources = link.getRole();
			Object theSource = sources.size() == 1 ? sources.get(0) : null;
			if (false == theSource instanceof Role) {
				continue;
			}
			Role src = (Role) theSource;
			if (src != source) {
				continue;
			}
			result.add(new UML_ERLinkDescriptor(src, dst, link,
					UML_ERElementTypes.Composition_4025,
					CompositionEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static final DiagramUpdater TYPED_INSTANCE = new DiagramUpdater() {
		/**
		 * @generated
		 */
		@Override
		public List<UML_ERNodeDescriptor> getSemanticChildren(View view) {
			return UML_ERDiagramUpdater.getSemanticChildren(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<UML_ERLinkDescriptor> getContainedLinks(View view) {
			return UML_ERDiagramUpdater.getContainedLinks(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<UML_ERLinkDescriptor> getIncomingLinks(View view) {
			return UML_ERDiagramUpdater.getIncomingLinks(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<UML_ERLinkDescriptor> getOutgoingLinks(View view) {
			return UML_ERDiagramUpdater.getOutgoingLinks(view);
		}
	};

	/**
	 * 
	 */
	private static Collection<UML_ERLinkDescriptor> getOutgoingFeatureModelFacetLinks_BinaryRelationship_Target_4022(
			BinaryRelationship source) {

		LinkedList<UML_ERLinkDescriptor> result = new LinkedList<UML_ERLinkDescriptor>();
		BinaryRelationship destination = source;
		if (destination == null || source.getAttribute().isEmpty()) {
			return result;
		}
		result.add(new UML_ERLinkDescriptor(source, destination,
				UML_ERElementTypes.BinaryRelationshipTarget_4022,
				BinaryRelationshipTargetEditPart.VISUAL_ID));
		return result;
	}

	public static List<UML_ERLinkDescriptor> getRelationshipAttributes_2005ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

}
